package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.WorkflowApplyLine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2019-08-01 15:48:23
 */
@Repository
public class WorkflowApplyLineDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(WorkflowApplyLineDao.class);

    public WorkflowApplyLine insert(final WorkflowApplyLine workflowApplyLine) {
        insert("WorkflowApplyLine.insert", workflowApplyLine);
        return workflowApplyLine;
    }

    public Boolean updateInfoById(final WorkflowApplyLine workflowApplyLine) {
        return update("WorkflowApplyLine.updateInfoById", workflowApplyLine) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("WorkflowApplyLine.updateInfoByQuery", query) > 0;
    }

    public WorkflowApplyLine selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("WorkflowApplyLine.selectById", query);
    }

    public List<WorkflowApplyLine> selectByQuery(final Query query) {
        return queryForList("WorkflowApplyLine.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("WorkflowApplyLine.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        WorkflowApplyLine workflowApplyLine = new WorkflowApplyLine();
        workflowApplyLine.setDeleteFlag(1);
        workflowApplyLine.setId(id);

        return update("WorkflowApplyLine.updateInfoById", workflowApplyLine) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Long id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("WorkflowApplyLine.deleteById", query) > 0;
    }
}